package com.jzl.swing.ui.model;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import com.jzl.swing.entity.Bill;
import com.jzl.swing.entity.BillReport;
import com.jzl.swing.entity.Supplier;
import com.jzl.swing.entity.SupplierReport;
import com.jzl.swing.entity.User;

public class ZaleTableModel extends AbstractTableModel{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	List<String> titleList = new ArrayList<String>(); 
	List<ArrayList<String>> rowList = new ArrayList<ArrayList<String>>();
	
	public ZaleTableModel(List<String> titleList, List<Bill> arrayList) {
		for (int i = 0; i < arrayList.size(); i++) {
			ArrayList<String> temp = new ArrayList<String>();
			temp.add(arrayList.get(i).getBill_number());
			temp.add(arrayList.get(i).getBill_product_name());
			temp.add(arrayList.get(i).getBill_product_number());
			temp.add(arrayList.get(i).getBill_price());
			temp.add(arrayList.get(i).getBill_ispaid());
			temp.add(arrayList.get(i).getBill_supplierName());
			temp.add(arrayList.get(i).getBill_product_decrib());
			temp.add(arrayList.get(i).getBill_date());
			rowList.add(temp);
		}
		this.titleList = titleList;
	}
	
	public ZaleTableModel(List<String> titleList, List<User> arrayList,int user) {
		for (int i = 0; i < arrayList.size(); i++) {
			ArrayList<String> temp = new ArrayList<String>();
			temp.add(arrayList.get(i).getUser_name());
			temp.add(arrayList.get(i).getUser_iden());
			rowList.add(temp);
		}
		this.titleList = titleList;
	}

	public ZaleTableModel(List<String> titleList, List<Supplier> arrayList, String supplier) {
		for (int i = 0; i < arrayList.size(); i++) {
			ArrayList<String> temp = new ArrayList<String>();
			temp.add(arrayList.get(i).getSupplier_id());
			temp.add(arrayList.get(i).getSupplier_name());
			temp.add(arrayList.get(i).getsupplier_describ());
			temp.add(arrayList.get(i).getsupplier_contacter());
			temp.add(arrayList.get(i).getsupplier_phone());
			temp.add(arrayList.get(i).getsupplier_address());
			rowList.add(temp);
		}
		this.titleList = titleList;
	}
	
	public ZaleTableModel(List<String> titleList, List<BillReport> arrayList, boolean b) {
		for (int i = 0; i < arrayList.size(); i++) {
			ArrayList<String> temp = new ArrayList<String>();
			temp.add(arrayList.get(i).getBill_product_name());
			temp.add(arrayList.get(i).getBill_product_number());
			temp.add(arrayList.get(i).getBill_price());
			temp.add(arrayList.get(i).getBill_supplierName());
			rowList.add(temp);
		}
		this.titleList = titleList;
	}
	
	public ZaleTableModel(List<String> titleList, List<SupplierReport> arrayList, boolean b, int j) {
		for (int i = 0; i < arrayList.size(); i++) {
			ArrayList<String> temp = new ArrayList<String>();
			temp.add(arrayList.get(i).getSupplier_id());
			temp.add(arrayList.get(i).getSupplier_name());
			temp.add(arrayList.get(i).getBill_price());
			temp.add(arrayList.get(i).getBill_product_number());
			rowList.add(temp);
		}
		this.titleList = titleList;
	}
	
	@Override
	public int getColumnCount() {
		return titleList.size();
	}

	@Override
	public int getRowCount() {
		return rowList.size();
	}

	@Override
	public Object getValueAt(int arg0, int arg1) {
		
		return rowList.get(arg0).get(arg1);
	}
	
	@Override
	public String getColumnName(int arg0) {
		return titleList.get(arg0);
	}

}
